package com.ruihu.admin.module.business.task.domain.vo;

import com.ruihu.admin.module.business.task.domain.dto.SubTaskDTO;
import com.ruihu.admin.module.business.task.domain.entity.SubTaskEntity;
import lombok.Data;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;

/**
 *  [ 任务子表 ]
 *
 * @author Tony
 * @version 1.0
 * @company 瑞虎（南京）信息技术有限公司
 * @copyright (c) 瑞虎（南京）信息技术有限公司Inc. All rights reserved.
 * @date  2022-08-29 17:13:25
 * @since JDK1.8
 */
@Data
public class SubTaskVO {

    @ApiModelProperty("主键")
    private Long id;

    @ApiModelProperty("子任务编号")
    private String taskCode;

    @ApiModelProperty("电芯编码")
    private String electricCoreCode;

    @ApiModelProperty("电芯型号编码")
    private String electricCoreType;

    @ApiModelProperty("电芯型号名称")
    private String electricCoreTypeName;

    @ApiModelProperty("主任务ID")
    private Long mainTaskId;

    @ApiModelProperty("当前任务节点实例ID")
    private Long currentTaskNodeInstId;

    @ApiModelProperty("任务状态")
    private String status;

    @ApiModelProperty("任务状态描述")
    private String statusText;

    @ApiModelProperty("任务完成时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date completionTime;

    @ApiModelProperty("任务执行人ID")
    private Long assigneeId;

    @ApiModelProperty("任务执行人名称")
    private String assigneeName;

    @ApiModelProperty("创建时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date createTime;

    @ApiModelProperty("更新时间")
    @JsonFormat(pattern = "yyyy-MM-dd HH:mm:ss", timezone = "GMT+8")
    private Date updateTime;

    @ApiModelProperty("任务创建人")
    private String createByName;

    @ApiModelProperty("任务更新人")
    private String updateByName;

    @ApiModelProperty("部门名称")
    private String departmentName;

    public static SubTaskVO convertToSubTaskVO(SubTaskDTO subTaskDTO) {
        if (subTaskDTO == null) {
            return null;
        }
        SubTaskVO subTaskVO = new SubTaskVO();
        subTaskVO.setId(subTaskDTO.getId());
        subTaskVO.setTaskCode(subTaskDTO.getTaskCode());
        subTaskVO.setElectricCoreCode(subTaskDTO.getElectricCoreCode());
        subTaskVO.setElectricCoreType(subTaskDTO.getElectricCoreType());
        subTaskVO.setElectricCoreTypeName(subTaskDTO.getElectricCoreTypeName());
        subTaskVO.setMainTaskId(subTaskDTO.getMainTaskId());
        subTaskVO.setCurrentTaskNodeInstId(subTaskDTO.getCurrentTaskNodeInstId());
        subTaskVO.setStatus(subTaskDTO.getStatus());
        subTaskVO.setCompletionTime(subTaskDTO.getCompletionTime());
        subTaskVO.setAssigneeId(subTaskDTO.getAssigneeId());
        subTaskVO.setAssigneeName(subTaskDTO.getAssigneeName());
        subTaskVO.setCreateTime(subTaskDTO.getCreateTime());
        subTaskVO.setUpdateTime(subTaskDTO.getUpdateTime());
        subTaskVO.setCreateByName(subTaskDTO.getCreateByName());
        subTaskVO.setUpdateByName(subTaskDTO.getUpdateByName());
        return subTaskVO;
    }

    public static SubTaskVO convertToSubTaskVO(SubTaskEntity entity) {
        if (entity == null) {
            return null;
        }
        SubTaskVO subTaskVO = new SubTaskVO();
        subTaskVO.setId(entity.getId());
        subTaskVO.setTaskCode(entity.getTaskCode());
        subTaskVO.setElectricCoreCode(entity.getElectricCoreCode());
        subTaskVO.setElectricCoreType(entity.getElectricCoreType());
        subTaskVO.setMainTaskId(entity.getMainTaskId());
        subTaskVO.setCurrentTaskNodeInstId(entity.getCurrentTaskNodeInstId());
        subTaskVO.setStatus(entity.getStatus());
        subTaskVO.setCompletionTime(entity.getCompletionTime());
        subTaskVO.setAssigneeId(entity.getAssigneeId());
        subTaskVO.setAssigneeName(entity.getAssigneeName());
        subTaskVO.setCreateTime(entity.getCreateTime());
        subTaskVO.setUpdateTime(entity.getUpdateTime());
        return subTaskVO;
    }
}
